package com.clpms.controller;

import com.clpms.bean.enumBean.ErrorCodeEnum;
import com.clpms.bean.req.SchoolAddReq;
import com.clpms.bean.resp.QuerySchoolResp;
import com.clpms.bean.resp.SchoolAddResp;
import com.clpms.bean.resp.TeacherAddResp;
import com.clpms.service.SchoolService;
import com.clpms.utils.CommonException;
import com.clpms.utils.ResultDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author caixinyong
 * @date 2023/5/5 4:11 PM
 */

@RestController
@RequestMapping("/school/v1")
@Slf4j
public class SchoolController {

	@Resource
	private SchoolService schoolService;

	//添加学校
	@PostMapping("/add")
	public ResultDto<TeacherAddResp> add(@RequestBody @Valid SchoolAddReq req) {
		SchoolAddResp addResp = schoolService.add(req);
		return ResultDto.Success(addResp);
	}


	@PostMapping("/queryAllSchool")
	public ResultDto<List<QuerySchoolResp>> queryAllSchool() {
		List<QuerySchoolResp> schoolRespList = schoolService.queryAllSchool();
		return ResultDto.Success(schoolRespList);
	}
}
